| Conditions | 3 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { CommandHandler } from '@nestjs/cqrs'; |
||
| 16 | |||
| 17 | public async execute(command: UpdateContactCommand): Promise<void> { |
||
| 18 | const { |
||
| 19 | id, |
||
| 20 | firstName, |
||
| 21 | lastName, |
||
| 22 | company, |
||
| 23 | email, |
||
| 24 | phoneNumber, |
||
| 25 | notes |
||
| 26 | } = command; |
||
| 27 | |||
| 28 | const contact = await this.contactRepository.findOneById(id); |
||
| 29 | |||
| 30 | if (!contact) { |
||
| 31 | throw new ContactNotFoundException(); |
||
| 32 | } |
||
| 33 | |||
| 34 | if (this.isContactEmpty.isSatisfiedBy(firstName, lastName, company)) { |
||
| 35 | throw new EmptyContactException(); |
||
| 36 | } |
||
| 37 | |||
| 38 | contact.update(firstName, lastName, company, email, phoneNumber, notes); |
||
| 39 | |||
| 40 | await this.contactRepository.save(contact); |
||
| 41 | } |
||
| 43 |